<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center searchye_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between searchye_fd0_0'>
					<text class='fu-iconfont2 searchye_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">&#xE794;</text>
					<view style="font-size: 36rpx;font-weight: 500;">搜索</view>
					<view class="searchye_fd0_0_c0"></view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---搜索记录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout searchye_flex_1">
				<view class='flex align-center searchye_fd0_0_c1'>
					<image class='searchye_fd0_0_c1_c0' mode="aspectFit" :src='STATIC_URL+"540.png"'></image>
					<input class='searchye_fd0_0_c1_c1' type="text" :placeholder="placeholder"
						confirm-type="search" :maxlength="-1" placeholder-style="color:#999;font-size:28rpx"
						style="font-family: PingFang SC, PingFang SC;" @confirm="addSearchHistoryFunc()"
						v-model="keyword" />
				</view>
				<view class='flex flex-wrap align-center searchye_fd1_0'>
					<view class='searchye_fd1_0_c0'>
						<image :src='STATIC_URL+"486.png"' mode="aspectFill"></image>
						<text>历史搜索</text>
					</view>
					<image class='searchye_fd1_0_c1' mode="aspectFit" :src='STATIC_URL+"541.png"'
						@tap.stop="popupShow1698292523708=true"></image>
				</view>
				<view class='flex flex-wrap align-center searchye_fd1_1' v-if=" appSearchHistory.length>=0">
					<template v-for='(item,key0) in appSearchHistory'>
						<view class='flex flex-wrap align-center searchye_fd1_1_c0' @tap.stop="handleJumpDiy"
							data-type="navigateTo"
							:data-url="`/pages/sousuo/recommendCommodityList/recommendCommodityList?keyword=${item.name}`"
							@longpress="handleLongpressFunc(item.name)" :key='key0'>
							<text class='searchye_fd1_1_c0_c0'>{{item.name}}</text>
							<image class='searchye_fd1_1_c0_c1' mode="aspectFit" :src='STATIC_URL+"198.png"'
								@tap.stop="deleteSearchHistoryFunc(item.name)" v-if=" key0==removeIndex"></image>
						</view>
					</template>

				</view>
				<text class='searchye_fd1_2' v-if=" appSearchHistory.length<=0">暂无历史记录</text>
			</view>

			<benben-popup v-model="popupShow1698292523708" :mask="true" :mask-close-able="true" mode='center'>
				<!---删除历史记录弹窗flex布局开始-->
				<view class="flex flex-direction flex-wrap align-center search_flex_2">
					<!-- <text class='search_fd2_0'>提示</text> -->
					<text class='search_fd2_1'>确定删除历史记录？</text>
					<view class='flex flex-wrap align-center search_fd2_2'>
						<button class='search_fd2_2_c0' @tap.stop="popupShow1698292523708=false">取消</button>
						<button class='search_fd2_2_c1' @tap.stop="emptySearchHistoryFunc()">确认</button>
					</view>
				</view>
			</benben-popup>
		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"popupShow1698292523708": false,
				"keyword": "",
				"dataList": [],
				"dataLists": [],
				"removeIndex": -1,
				"keyList": [],
				"placeholder": "搜索",
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			appSearchHistory() { // 搜索历史
				return this.$store.state.appSearchHistory
			}
		},
		watch: {},
		onLoad(options) {
			// this.getNewsNum();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//搜索默认值
			// getNewsNum() {
			// 	this.$api.post(global.apiUrls.post64feac3aa90f4, {

			// 	}).then(res => {
			// 		if (res.data.code == 1) {
			// 			this.placeholder = res.data.data.keyword;
			// 		} else {
			// 			this.$message.info(res.data.msg);
			// 		}
			// 	})
			// },
			goSearch(keyword) {
				this.$urouter.navigateTo(
					`/pages/sousuo/recommendCommodityList/recommendCommodityList?keyword=${keyword}`);
			},
			//长按事件
			handleLongpressFunc(index) {
				this.removeIndex = index;
			},
			//添加搜索历史
			addSearchHistoryFunc() {
				if (!this.keyword) {
					this.placeholder = this.keyword;
				}
				this.$store.commit('appSearchHistoryAdd', {
					"name": this.keyword
				})
				this.$urouter.navigateTo(
					`/pages/sousuo/recommendCommodityList/recommendCommodityList?keyword=${this.keyword}`);
			},
			//删除搜索历史
			deleteSearchHistoryFunc(name) {
				this.$store.commit('appSearchHistoryDel', {
					"name": name
				})
			},
			//清空搜索记录
			emptySearchHistoryFunc() {
				this.$store.commit('appSearchHistoryClean', '')
				this.popupShow1698292523708 = false;
			},

		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: var(--benbenbgColor1);
		background-size: 100% auto;
	}

	.searchye_flex_0 {
		width: 750rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
		border-bottom: 1px solid #eee;
	}

	.searchye_fd0_0_c1_c1 {
		margin: 0rpx 0rpx 0rpx 16rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #333;
		flex: 1;
		height: 100%;
	}

	.searchye_fd0_0_c1_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchye_fd0_0_c1 {
		background: #f9f9f9;
		background-size: 100% auto !important;
		border-radius: 36rpx 36rpx 36rpx 36rpx;
		width: 686rpx;
		height: 64rpx;
		margin: 0 32rpx;
		padding: 0 24rpx;
	}

	.searchye_fd0_0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
		width: 50rpx;
	}

	.searchye_fd0_0 {
		margin: 0rpx 30rpx 0rpx 30rpx;
		width: 100%;
	}

	.searchye_flex_1 {
		background: #FFFFFF;
		padding: 0rpx 0rpx 0rpx 0rpx;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.searchye_fd1_2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #666666;
		margin: 0rpx 0rpx 32rpx 24rpx;
	}

	.searchye_fd1_1_c0_c1 {
		width: 18rpx;
		height: 18rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchye_fd1_1_c0_c0 {
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(51, 51, 51, 1);
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.searchye_fd1_1_c0 {
		background: #f8f8f8;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		background-size: 100% auto !important;
		padding: 0rpx 40rpx 0rpx 40rpx;
		line-height: 56rpx;
		margin: 0rpx 12rpx 24rpx 12rpx;
	}

	.searchye_fd1_1 {
		padding: 0rpx 0rpx 0rpx 18rpx;
	}

	.searchye_fd1_0_c1 {
		width: 24rpx;
		height: 28rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.searchye_fd1_0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
		display: flex;
		align-items: center;
		image {
			width: 34rpx;
			height: 34rpx;
			margin-right: 16rpx;
		}
	}

	.searchye_fd1_0 {
		padding: 40rpx 0rpx 24rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 24rpx;
	}

	.searchye_fd2_0_c0_c2_c1_c0 {
		color: #FFFFFF;
		font-size: 34rpx;
		font-weight: 400;
	}

	.searchye_fd2_0_c0_c2_c1 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/694.png) no-repeat;
		height: 71rpx;
		width: 191rpx;
		margin: 0rpx 0rpx 0rpx 16rpx;
		background-size: 100% auto;
	}

	.searchye_fd2_0_c0_c2_c0_c0 {
		color: #796446;
		font-size: 34rpx;
		font-weight: 400;
	}

	.searchye_fd2_0_c0_c2_c0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/693.png) no-repeat;
		height: 71rpx;
		width: 191rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
		background-size: 100% auto;
	}

	.searchye_fd2_0_c0_c2 {
		margin: 0rpx 0rpx 70rpx 0rpx;
	}

	.searchye_fd2_0_c0_c1 {
		line-height: 44rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
		margin: 40rpx 0rpx 71rpx 0rpx;
		text-align: center;
	}

	.searchye_fd2_0_c0_c0 {
		color: #333333;
		font-size: 40rpx;
		font-weight: 400;
		margin: 190rpx 0rpx 0rpx 0rpx;
	}

	.searchye_fd2_0 {
		width: 580rpx;
		background-size: 100% auto;
	}

	.searchye_fd3_1_c0_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 400;
		line-height: 40rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.searchye_fd3_1_c0 {
		background: #F7F6F4;
		border-radius: 35rpx;
		padding: 12rpx 32rpx 12rpx 32rpx;
		margin: 0 24rpx 24rpx 0;
	}

	.searchye_fd3_1 {
		width: 687rpx;
		margin: 0rpx auto 0rpx auto;
	}

	.searchye_fd3_0_c0 {
		font-size: 32rpx;
		font-weight: 700;
		color: rgba(51, 51, 51, 1);
	}

	.searchye_fd3_0 {
		padding: 32rpx 0rpx 15rpx 0rpx;
		margin: 0rpx 30rpx 32rpx 30rpx;
	}
	
	.search_flex_2 {
		background: #fff;
		margin: 0rpx 105rpx 0rpx 105rpx;
		background-size: #eee;
		border-radius: 25rpx 25rpx 25rpx 25rpx;
		padding: 40rpx 0rpx 0rpx 0rpx;
	}
	
	.search_fd2_2_c1 {
		background: transparent;
		line-height: 90rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: #47AAEE;
		width: 269rpx;
		height: 90rpx;
	}
	
	.search_fd2_2_c0 {
		border-right: 1px solid #EEEEEE;
		background: transparent;
		line-height: 90rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: #999;
		height: 90rpx;
		width: 270rpx;
	}
	
	.search_fd2_2 {
		border-top: 1px solid #eee;
	}
	
	.search_fd2_1 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
		margin: 60rpx 0rpx 70rpx 0rpx;
	}
	
	.search_fd2_0 {
		color: #333333;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 45rpx;
	}
</style>